package com.ruoyi.tcsp.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.tcsp.domain.bean.req.TcspSciEvalReq;
import com.ruoyi.tcsp.domain.bean.resp.SciEvalResp;
import com.ruoyi.tcsp.service.ITcspSciEvalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;
import java.util.List;

@RestController
@RequestMapping("/tcsp/sciEval")
public class TcspSciEvalController extends BaseController {
    @Autowired
    private ITcspSciEvalService iTcspSciEvalService;

    @PermitAll
    @PostMapping()
    public AjaxResult scienEval(@RequestBody TcspSciEvalReq req){
        String username = getLoginUser().getUser().getNickName();
        int res = iTcspSciEvalService.scienEval(req, username);
        return AjaxResult.success();
    }

    @PermitAll
    @GetMapping("/{scienId}")
    public AjaxResult getScienEval(@PathVariable("scienId") String scienId){
        List<SciEvalResp> data = iTcspSciEvalService.getScienEval(scienId);
        return AjaxResult.success(data);
    }
}
